package cn.ismartv.viewpagerindicatorsample;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.ViewPager;

import java.util.ArrayList;

import cn.ismartv.viewpagerindicator.FragmentPager;
import cn.ismartv.viewpagerindicator.IconPagerIndicator;
import cn.ismartv.viewpagerindicator.IndicatorFragmentPagerAdapter;

public class MainActivity extends FragmentActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        ArrayList<FragmentPager> arrayList = new ArrayList<>();

        FragmentPager fragmentPager = new FragmentPager();
        fragmentPager.setFragment(new FirstFragment());
        fragmentPager.setIconResId(R.mipmap.ic_launcher);
        arrayList.add(fragmentPager);

        fragmentPager = new FragmentPager();
        fragmentPager.setFragment(new SecondFragment());
        fragmentPager.setIconResId(R.mipmap.ic_launcher);
        arrayList.add(fragmentPager);


        fragmentPager = new FragmentPager();
        fragmentPager.setFragment(new ThirdFragment());
        fragmentPager.setIconResId(R.mipmap.ic_launcher);
        arrayList.add(fragmentPager);

        ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);

        viewPager.setAdapter(new IndicatorFragmentPagerAdapter(getSupportFragmentManager(), arrayList));

        IconPagerIndicator iconPagerIndicator = (IconPagerIndicator) findViewById(R.id.indicator);
        iconPagerIndicator.setViewPager(viewPager);
    }
}
